package com.jinniulive.platform.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jinniulive.platform.R;

import java.util.List;

/**
 * Created by Administrator on 2016/12/13.
 */

public class GiftBaseAdapter extends BaseAdapter{
    private Context mContext;
    private List<String> mList;

    public GiftBaseAdapter(Context context, List<String> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public int getCount() {
        return mList==null?0:mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHodleer viewHodleer=null;
        if (convertView ==null ){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_spinner,parent,false);
            viewHodleer=new ViewHodleer();
            viewHodleer.mTextView = (TextView) convertView.findViewById(R.id.item_spinner_tv);
            convertView.setTag(viewHodleer);
        }else {
            viewHodleer= (ViewHodleer) convertView.getTag();
        }
        viewHodleer.mTextView.setText(mList.get(position));

        return convertView;
    }

    class ViewHodleer{
        private TextView mTextView;

    }


}
